﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp1
{
    class DnHelper
    {
        private static string conSrting = "server=.database=Blogs;uid=luhan;pwd=123456";
        public static DataTable GetDataTable(string sql)
        {
            SqlConnection Connection = new SqlConnection(conSrting);
            SqlDataAdapter Dataadapter = new SqlDataAdapter(sql, Connection);
            DataTable dt = new DataTable();
            Connection.Open();
            Dataadapter.Fill(dt);
            return dt;
        }
        public static int AddOrEditOrDeleteSave(string sql)
        {
            SqlConnection Connection = new SqlConnection(conSrting);
            SqlCommand sqlCommand = new SqlCommand(sql, Connection);
            Connection.Open();
            return sqlCommand.ExecuteNonQuery();
        }
    }
}

